package wb.is.besti.edu.cd.javalibgame;

/**
 * Created by Mr.Z on 2017/12/17.
 */

public class insertionSort {
    public void insertionSort(int[] data) {
        for (int index = 1; index < data.length; index++) {
            int key = data[index];
            int position = index;

            // Shift larger values to the right
            while (position > 0 && data[position - 1] > key) {
                data[position] = data[position - 1];
                position--;
            }

            data[position] = key;
        }
    }
}
